package com.zhuhjay.utils;

import com.zhuhjay.model.entity.SystemUser;
import com.zhuhjay.security.LoginUserDetail;

/**
 * 增强SecurityContextHolder，便于使用
 * @author ZhuHJay
 * @date 2023/2/4 22:35
 */
public class SecurityContextHolder {

    /** 获取登录用户的token信息 **/
    public static LoginUserDetail getLoginUserDetail() {
        return (LoginUserDetail) org.springframework.security.core.context.SecurityContextHolder
                .getContext().getAuthentication().getPrincipal();
    }

    /** 获取登录用户的完整信息 **/
    public static SystemUser getUser() {
        return getLoginUserDetail().getUser();
    }

}
